<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2021/8/25 0025
 * Time: 下午 2:50
 */
namespace app\model;
class UserStudentDynamic extends \think\Model{
    public $table="school_student_dynamic";

    /**
     * 发表动态
     * @param $data
     * @return int|string
     */
    function add_dynamic($data){
        $data2['content']=$data['content'];
        $data2['pic']=$data['pic'];
        $data2['user_id']=$data['user_id'];
        $data2['school_id']=$data['school_id'];
        $data2['created_at']=cur_time();
        return $this->insertGetId($data2);
    }


    /**
     * 返回所有的动态信息列表
     * @param $school_id
     * @param int $cur_page
     */
    function get_page_list($school_id,$cur_page=1){

        $page_size=10;
        $offset=($cur_page-1)*$page_size;

        $o=$this->where(['school_id'=>$school_id])->limit($offset,$page_size)->select();
        $arrs=object2array($o);
        $UserResume=new UserResume();
        $User=new User();
        foreach($arrs as $k=>$v){
            $user_info=[];
            $ur_arr=$UserResume->get_head_img_name_by_user_id($v['user_id']);
            $user_info['head_img']=$ur_arr['head_img'];
            $user_info['name']=$ur_arr['name'];
            $u_arr=$User->get_user_info_by_id($v['user_id']);
            $user_info['exp_job']=$ur_arr['exp_job'];
            $arrs[$k]['user_info']=$user_info;
        }
        return $arrs;

    }


}